package com.mengyu.moeisland.bean




import com.facebook.stetho.okhttp3.StethoInterceptor

import com.mengyu.moeisland.net.TokenInterceptor
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory


class  HttpAPI {

    companion object{

        val showLog= true

        private fun getClient():OkHttpClient{
            val client =  OkHttpClient.Builder()
                .apply {
                    addInterceptor(TokenInterceptor())
                    if(showLog){
                        addInterceptor(HttpLoggingInterceptor().apply { level=HttpLoggingInterceptor.Level.BODY })
                        addNetworkInterceptor(StethoInterceptor())
                    }
                }.build()
            return client
        }

         val retrofit: Retrofit by lazy {
                 val builder = Retrofit.Builder()
                .baseUrl("BuildConfig.ENDPOINT")
//                .baseUrl(BuildConfig.ENDPOINT)
//                .addConverterFactory(StringConverterFactory.create())
                .addConverterFactory(GsonConverterFactory.create())
                 builder.client(getClient())
                 builder.build()
        }

//        val apiterface: APIterface by lazy {
//               retrofit.create(APIterface::class.java)
//        }


}





}